<template>
    <div class="h100 w100 flex_col_start">
        <div class="flex_row m5 p10 card">
            <label>阶段:</label>
            <el-input v-model="ctx.vote_id" clearable style="width: 300px; margin-left: 10px;"/>
            <el-button @click="onClickSet" type="primary" class="ml5">设置</el-button>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { set_current } from '@/service/api';
import { runAction } from '@/utils/ui';
import { reactive } from 'vue';


interface Ctx {
    vote_id: string,
}

const ctx = reactive<Ctx>({
    vote_id: '1'
});

// async function init() {
//     const infos = await query_vote_info();
//     console.log(infos);
// }   

// init();

async function onClickSet() {
    await runAction('设置', '设置阶段', async () => {
        const vote_id = parseInt(ctx.vote_id);
        if (isNaN(vote_id)) {
            throw '请输入正确的阶段';
        }
        await set_current(vote_id);
    });
}


</script>
